package com.feicheng.common.config;

import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.ServerSentEventHttpMessageWriter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.reactive.config.WebFluxConfigurer;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

@Configuration
public class WebConfig implements WebFluxConfigurer {

    @Override
    public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
        configurer.defaultCodecs().enableLoggingRequestDetails(true);
        configurer.customCodecs().writer(new ServerSentEventHttpMessageWriter());
//        configurer.defaultCodecs().stringHttpMessageWriter(writer -> writer.useDefaultCharset(StandardCharsets.UTF_8)); // 设置默认字符集为UTF-8
    }

}
